package hust.music.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hust.music.action.base.ActionBase;
import hust.music.service.PlayListModService;

@Controller
@Scope("session")
public class AddMusicToListAction extends ActionBase {

	private static final long serialVersionUID = 1L;
	
	@Autowired
	private PlayListModService playListModService;
	
	private Integer listId;
	private Integer musicId;
	private String flag;
	
	public String getFlag() {
		return flag;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public Integer getListId() {
		return listId;
	}
	public void setListId(Integer listId) {
		this.listId = listId;
	}
	public Integer getMusicId() {
		return musicId;
	}
	public void setMusicId(Integer musicId) {
		this.musicId = musicId;
	}
	
	public String add(){
		try {
			if(playListModService.addMusicToList(listId, musicId)){
				flag="1";
			}else{
				flag="0";
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			flag=e.getMessage();
		}
		return "add";
	}
}
